﻿@{
   
    var _url = ViewBag.ActiveUrl as ForumUrl;

    var _list = ViewBag.List as List<IPLock>;
        
}
@model IPLock
<div class="site-block">
    <div class="header">
        @_url.Title
    </div>
    @using(Html.Kaio().BeginForm(new jQueryAjaxOptions(){Loading = true},new {@id="_f"}))
    {
        
    
    @Html.HiddenFor(x => Model.Id)
    @Html.Hidden("returnUrl", _url.Url)
    <div class="site-block-content">
        <table>
            <tr>
                <td class="w25">
                    @ForumContext.GetMvcText(LanguageSection.IPLOCKS, "IP_MASK")
                </td>
                <td>
                    @Html.TextBox("mask", Model != null ? Model.Mask : Request.QueryString["IP"], new { @class = "input {validate:{required:1}}" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.IPLOCKS, "EXPIRES")
                </td>
                <td>
                    @Html.TextBoxFor(x => Model.Expires, new { @class = "input datepicker {datetimeFormat:'O/D/Y H:M a',minDatetime:new Date()}" })
                </td>
            </tr>
            <tr>
                <td>
                    @ForumContext.GetMvcText(LanguageSection.IPLOCKS, "REASON")
                </td>
                <td>
                    @Html.TextAreaFor(x => Model.Reason, new { @class = "input" })
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    @Html.Link("javascript://", (string)ViewBag.ButtonText, new { @class = "ui-button", onclick = "$('#_f').submit()" })

                    @Html.Link(_url.Url, ForumContext.GetText(LanguageSection.GLOBAL, "Cancel"), new { @class = "ui-button"})
                    
                </td>
            </tr>
        </table>
    </div>
    }
</div>
@if (_list != null && _list.Count > 0)
{
    
    <form action="@_url.Url" id="_fl">
    @Html.Hidden("act", "del")
    @Html.Hidden("returnUrl", _url.Url)
    <div class="gridview white-t">
        <div class="head">
            @ForumContext.GetText(LanguageSection.IPLOCKS, "IP_LIST")
        </div>
        <table class="datatable">
            <tr>
                <th class="header w5" scope="col">
                    <input type='checkbox' onclick='$.MvcForum.toggleCheckbox(this.checked)' />
                </th>
                <th class="header" scope="col">
                    @ForumContext.GetText(LanguageSection.IPLOCKS, "IP_MASK_HEAD")
                </th>
                <th class="header" scope="col">
                    @ForumContext.GetText(LanguageSection.IPLOCKS, "EXPIRES_HEAD")
                </th>
                <th class="header" scope="col">
                    @ForumContext.GetText(LanguageSection.IPLOCKS, "REASON_HEAD")
                </th>
                <th class="header" scope="col">
                    @ForumContext.GetText(LanguageSection.GLOBAL, "OPTIONS")
                </th>
            </tr>
            @foreach (IPLock m in _list)
            {
                        
                <tr class="row">
                    <td class="center">
                        <input type="checkbox" name="Ids" value="@m.Id" class="selected" />
                    </td>
                    <td class="@string.Format("{0}", m.Expires < DateTime.UtcNow ? "del" : string.Empty)">
                        @m.Mask
                    </td>
                    <td>
                        @ForumContext.PrettyDate(m.Expires) 
                    </td>
                    <td class="w30">
                        @m.Reason
                    </td>
                    <td class="center width10">                

                        @Html.Link(string.Format("{0}?Id={1}", _url.Url, m.Id), "", new { @class = "ui-button icon-16 edit" })
                    </td>
                </tr>
                        
            }
        </table>
    </div>
    <div class="white-t">
        @Html.Link("javascript:void(0)", "", new { @onclick = "$.KoolBox.confirm('" + ForumContext.GetText(LanguageSection.MESSAGES, "DELETE_CONFIRM") + "',{title:'Confirm'},function(r){if(r){$.MvcForum.ajaxSubmit('_fl')}})", @class = "ui-button icon-16 del" })
    </div>
    </form>
    
}


<script type="text/javascript">
    $(function () {
        $('.datepicker').datetimeEntry();
    })
</script>